<?php

	/**
	 * File : menu_bar.php
	 * Description : Définition et fonctions du composant de la barre de menu
	 * Date : 07.08.2012 15:12:54
	 * 
	 * This file is part of Phenix.  Phenix is free software: you can
	 * redistribute it and/or modify it under the terms of the GNU General Public
	 * License as published by the Free Software Foundation, version 2.
	 *
	 * This program is distributed in the hope that it will be useful, but WITHOUT
	 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
	 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
	 * details.
	 *
	 * You should have received a copy of the GNU General Public License along with
	 * this program; if not, write to the Free Software Foundation, Inc., 51
	 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
	 *
	 * Nils Schaetti <n.schaetti@gmail.com>
	**/

	/*
	 * Fichiers requis
	*/
	require_once('menu_bar_button.php');

	/*
	 * Cette classe représente une barre de menu
	 */
	class ktkMenuBar implements KTKWidgets
	{
	
		/****************************************
		 * PROPRIÉTÉS
		 ****************************************/
	
		/*
		 * Taille des icones
		 */
		private $IconSize;
		
		/*
		 * Boutons
		 */
		private $Buttons;
		
		/**
		 * Nom de la barre
		 */
		private $Name;
	
		/****************************************
		 * FIN PROPRIÉTÉS
		 ****************************************/
	
		/*
		 * Constructeur
		 */
		function ktkMenuBar($Name)
		{
			$this->Name = $Name;
			$this->Buttons = array();
		}
	
		/**************************************
		 * FONCTIONS
		 **************************************/
	
		/*
		 * Ajoute un bouton
		 */
		public function addButton($name, $button)
		{
			// Ajoute
			$this->Buttons[$name] = $button;
		}
	
		/*
		 * Retourne le code de la barre de menu
		 */
		function getCode()
		{
			$buttons_code = '';
		
			// Code HTML
			$code = <<< __DELIMITER__
<div class="ktkMenuBar" id="{$this->Name}">
	<div class="ktkIconBar">
		@@_BUTTONS_@@
	</div>
</div>
__DELIMITER__;

			// Pour chaque bouton
			foreach($this->Buttons as $Button)
				$buttons_code .= $Button->getCode();
				
			// Remplacement
			$code = str_replace('@@_BUTTONS_@@',$buttons_code,$code);
			
			// Retourne le code
			return $code;
		}
		
		/*
		 * Affiche la barre de menu
		 */
		public function Show()
		{
			echo $this->getCode();
		}
		
		/****************************************
		 * FIN DE FONCTIONS
		 ****************************************/
	
	}

?>
